FileList
File ListView components for Delphi 2
© Amedeo Lanza di Casalanza amldc@tin.it

File ListView Components for Delphi 2
description:
FileList is a set of components based on TlistView control and Explorer’s File Window features.
TFileView is a ListView which links system image lists on creation and can accept files dropped from Windows' Explorer.
TFileList is a FileView descendant wich encapsulates some system functions to mix ancestor's capability with the FileListBox's Directory and Mask properties. Thus specifying a path name and a file mask, the control will be filled with the list of matching files, showing proper icons and a customizable set of file informations (more than found in the Explores's file window).
compatibility
I did not test it with Delphi 3 nor NT, but some users reported me this  works fine with them.
I had a report (and fixed upon suggestion) of a warning message under NT (see  v2.0 release notes)
Also I had a report (for Delphi 3) of GPF starting the program with  the MultiSelect property set to true. I did not fix this as I tested it with  new version (and Delphi 2), and did not find such problem. See the Known limitations section for further informations.
copyright & license
This software is Copyright © of Amedeo Lanza di Casalanza. You may freely use, modify and distribute this software for non commercial purposes and for writing freeware and/or shareware software. You MAY NOT SELL this software although you may include it in software collection you distribute, provided there is no charge for the software itself. 
Please leave the copyright information and any additional information (readme.* ecc.) provided with the original author's copy.

Use of this software for building of commercial programs should be expressely authorized by the author.
Any use of this software for illegal activities is prohibited.

If you enhance this software or fix any bug, please send the new source to the author.
DISCLAIMER:
I ASK NO FEE and I GIVE NO WARRANTY for this software, either expressed or implied. USE it AT YOUR OWN RISK.
suggestions, bug reports & comments to the author:
Amedeo Lanza di Casalanza
from: Torino, Italy
mailto:amldc@tin.it
http://volftp.tin.it/IT/IT/COLLABORAZIONI/LANZA/index.htm

WARNING FOR EMAIL ABUSE:
BORLAND DELPHI related messages are WELCOME, any other use of the author's email address for unsolicited ADVERTISING is STRICTLY PROHIBITED.
aknowledgement:
Portions of this software come from freeware examples by
Markus Stephany
MirBir.St@T-Online.de
http://home.t-online.de/home/MirBir.St/
wich I found on Delphi Super Page (http://SunSITE.icm.edu.pl/delphi/)
also thanks for hints to the very good "Unofficial Newsletter of Delphi Users" (UNDU) at http://www.informant.com/undu/index.htm

User defined types
TFileType
Name	Attribute bit	Default	
FtArchive	Archive file	on	
FtReadonly	Readonly file	on	
FtSystem	System file	off	
FtHidden	Hidden file	off	
FtTemporary	Temporary file	off	
FtAll	Any file	off	

TFileInfo
Name	File Informations	Default	
FiName	file name	on	
FiSize	file size	on	
FiType	file type as registered by windows	on	
FiModified	date of last write	on	
FiCreated	date of creation	off	
FiLastAccess	date of last access	off	
FiAttributes	Attributes	off	
FiDosName	Alternate (DOS) name (8.3)	off	
FiDosExt	Alternate (DOS) extension	off	
FiPath	file's directory	off	
FiAll	Display all columns	off	

TFLInsertEvent
procedure (Sender: TObject; Item: TListItem; Path: string; FindData :TWin32FindData)
TFileDropEvent
procedure (Files: Tstrings; X, Y: Integer)
TFileView class
properties:
AcceptFiles
boolean This property enables or disables file drop. Default is disabled.
OnFileDrop
TFileDropEvent callback for event FileDrop (see FileAdd event)

All properties published by TListView are also published, execpt for
LargeImages	load system image list in the create method	
SmallImages	load system image list in the create method	
StateImages	not used	

public methods:
function AddFile (Filename :TFilename) :TlistItem;
Add specified file. The component will add an item, get the Windows 95 display name for the item caption and to set proper icon index. Returns the newly added item.
events:
FileDrop
The TFileDropEvent callback procedure FileDrop (Files: Tstrings; X, Y: Integer) is called when files are dropped from Explorer into the control window.
•	Files: a string list containing dopped files pathanemes
•	X,Y: drop cohordinates
comments:
Uses FindFirstFile, FindNextFile and FindClose API calls from Windows unit to retrieve file list with better performances and ShGetFileInfo to retrieve extended informations.
To find help about TWin32FindData look for WIN32_FIND_DATA in the Win32 Programmer's Reference and TWin32FindData in Windows unit (if you have the RTL sources you can find it in the source\rtl\win directory.
TFileList class
properties:
Directory
string Setting this property will cause TFileList to scan the specified path list for files and load its items with files informations. A list in the form dir1;dir2;dir3 may be used. An empty string will prevent the directory scan
DisplayDirectory
boolean If set to TRUE will enable the loading of directories' info, when FALSE the directories will be ignored.
FyleTypes
TFileTypes Set of file attributes used in file search. Use this attribute to hide or display system/hidden files.
Mask
string File specifications list as in a TFilterComboBox.Mask. May be single file spec or list of filespecs separated by semicolon or commas (always returns with semicolons).
OnFileAdd
TFLInsertEvent callback for event FileAdd (see FileAdd event)
OnFileDrop
TFileDropEvent callback for event FileDrop (see FileAdd event)
SortColumn
TFileInfo Column to be used for sorting
ViewColumns
TfileInfos Set of TFileInfo used to select the desired columns to display. Each column is associated to a file information.

All properties published by TListView are also published, execpt for
Columns	handled by internal routines
LargeImages	load system image list in the create method
SmallImages	load system image list in the create method
StateImages	not used
public methods:
function AddFile (Filename :TFilename) :TlistItem;
Add specified file. The component will add an item with all informations specified by ViewColumns.
procedure AddMask (Mask :string)
Add specified file mask list to current file mask. May add single file spec or list of filespecs separated by semicolon or commas
procedure AddPath (Path :string)
Add a path specification to the search directory list. May add single filespec or list of filespecs separated by semicolon.
procedure SetColCaption (Col: TFileInfo; Value :string)
Set specified column's title to Value
procedure SetColWidth  (Col: TFileInfo; Value :integer)
Set the specified column's width to value
events:
ColClick
This method method is overridden in order to call the sort ruotine before the OnColumnClick custom handler.
FileAdd
The TFLInsertEvent callback procedure FileAdd (Sender: TObject; Item: TListItem; Path: string; FindData :TWin32FindData) is called after an item is inserted into the list. You can use this feature to take control over the item’s contents or maintain progress counters. The parameters used in FileAdd are:
•	Sender: the FileList sending the message
•	Item: a pointer to the newly inserted item
•	Path: the directory path of the file
•	FindData: a Win32FinData structure containing retrieved data from system
FileDrop
The TFileDropEvent callback procedure FileDrop (Files: Tstrings; X, Y: Integer) is called when files are dropped from Explorer into the control window.
•	Files: a string list containing dopped files pathanemes
•	X,Y: drop cohordinates
comments:
The MaskSearch unit is the one found in the MSTGREP.ZIP archive from marcus Stephany; I just added a Case Match capability for needed for a new component I’m developing. You may find the original archive on DSP.
Uses FindFirstFile, FindNextFile and FindClose API calls from Windows unit to retrieve file list with better performances and ShGetFileInfo to retrieve extended informations.
To find help about TWin32FindData look for WIN32_FIND_DATA in the Win32 Programmer's Reference and TWin32FindData in Windows unit (if you have the RTL sources you can find it in the source\rtl\win directory.
current known limitations :
•	Tested only with Delphi 2.0 and Win95 (OSR2), requires anyway Win32s,Win95 or WinNT as uses Win32 API calls.
•	Handles only File Items, System Resources cannot be displayed as in an Explorer's window.
•	Columns order is fixed, and settings of columns' width and caption is quite trivial; I hope I (or someone else) will be able to add a property editor for that.
history:
v2.0
25-sep-1997 - amldc@tin.it
•	Wrong item was reported when "\" leaking at end of used path. Fixed by ensuring loaded path strings always end with a "\".
•	Added check to prevent SortColumn being set to unused column.
•	Splitted code, inserted TFileListView as ancestor and TFileView.
•	TFileListView embeds System Image List handling and File Drop
•	AddFile is now a virtual method for both types and behave quite in a different way: in TFileView provides to get the needed informations
•	Added TFLInsertEvent type and OnFileAdd property
•	Added ability to get files dropped from Explorer
•	Added fix to avoid warning message under WinNT when setting directory to an empty drive (thanks to Sebastian Hildebrandt <hildebrandt@t0.or.at>)
•	Updated for my modified version of MaskSearch (with case match handling). This feature is not fully tested.
v1.1
14-sep-1997 - amldc@tin.it
•	Added SetupFileColumns in SetColWidth, needed if changing widths when component visible.
•	Modified SetDirectory to allow empty directory and skipping of directory scan.
•	Added support for directory list specification.
•	Added usage of Marcus Stephany's MaskSearch unit (see dependencies note above) for file search and support for file mask list specification.
•	Added FileTypes property for file attribute based filtering
•	DOS file name (cAlternateFilename) forced to Win file name (cFilename) when returned empty (in Win32FindData) from FindFirstFile and FindNextFile.
•	Added fiDosExt column (mainly for DOS extension based sorting)
•	Added fiAll (display all columns) and modified default set of columns to reflect the Explorer's one.
v1.0
10-aug-1997 amldc@tin.it
•	first development of the TFileList control
Installation
As for any other component: copy the FileList.pas and FileList.dcr into your vcl's directory, then use Components/Install function from Delphi IDE and select FileList.pas. The TFileList component will be added to the Win95 controls page. The MaskSearch unit should be copied to a library search directory.

Files in the original release:
•	FileList.pas	Delphi units containing TFileList class source
•	FileList.dcr	Resource file with TFileList bitmap
•	FileList.rtf	Docs in RTF format
•	FileList.txt	Readme file
•	FListxxx.inf	inf file for archive upload to DSP
•	MaskSearch.pas	Utility unit from the MstGrep.zip archive (by Marcus Stephany). This is included for your convenience, please check on DSP for full and updated releases of MstGrep.
Usage
Just drop a TFileList on a form, add a DirList (or better a DirTree by Markus Stephany) and a line of code to update the FileList's Directory property upon changing of DirList's Directory. Also you may wanto to add a FilterComboBox (or better a PathComboBox by Angus Johnson) and again write a line of code to update the TFileList's Mask upon changing of FilterComboBox's one.

Columns' captions and widths can be customized using the  SectColCaption and SetColWidth public procedures and Clicking on a column header (when in Details View mode) will sort the list using that column. A click on the header of the current sort column will invert the sort order. Note thad directory entries will be always shown on top. You may use the DisplayDirectory property to prevent directories from being included in the file list..

File masks are added using the AddMask procedure. Be warned that TFileList defaults to '*.*', so you have to set Mask to an empty string before adding masks.
The file list will be updated when Directory, Mask or  FileTypes properties are changed. When Directory is set to a null value, the list will be cleared and directory scan is inhibited; you may use this feature to prevent multiple reloading while setting other properties wich would do it (as Mask and FileTypes).
The values for Directory and Mask may be lists of specifications, the FileList component will load all files matching any of the Mask’s patterns found in any of the paths specified in Directory.

You may trap file dropping from Explorer with the OnFileDrop event, wich may be inhibited by setting the AcceptFiles property to false.

You may also find an example program implementing a simple Explorer Window wich shows how to interact with the TFileList control. Look for XEXPLxxx.ZIP on DSP freeware section. Note that the sample program requires some other cool freeware VCLs (as Toolbar97, DirTree and PathComboBox), not included in that archive; see withcome documentation for availability.